<html>
<head><meta charset="utf-8"><title>Setup for rustfmt · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html">Setup for rustfmt</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="245367616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245367616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Ardent <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245367616">(Jul 08 2021 at 20:27)</a>:</h4>
<p>Hey Cargo team! I recently submitted a <a href="https://github.com/rust-lang/cargo/pull/9663">PR</a>, and as part of that, did a <code>rustfmt</code> on my changed file. This wound up updating a submodule as well (not tragic, just coalesced a couple imports, but technically not really related to my change). When I ran <code>cargo fmt</code>, though, it reformatted dozens of files (over 100) from all over the repository, completely unrelated to my changes, and I did not include them.</p>
<p>That was using a recent nightly toolchain, though. Using stable resulted in a saner set of things formatted. However, it was accompanied by a bunch of warnings, eg, <code>Warning: can't set `wrap_comments = true`, unstable features are only available in nightly channel.</code>.</p>
<p>So my question is, which version of <code>rustfmt</code> should we be using to format our code for submission?</p>



<a name="245367840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245367840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245367840">(Jul 08 2021 at 20:29)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="240346">@Joe Ardent</span> !  Stable or nightly should work, it usually doesn't change often.  It sounds like maybe you have some configuration files or something interfering?</p>



<a name="245367984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245367984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Ardent <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245367984">(Jul 08 2021 at 20:30)</a>:</h4>
<p>oooh, darnit, I have a stray  .rustfmt.toml in a parent dir with a few things that would explain the non-default fmt behavior</p>



<a name="245368039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245368039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Ardent <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245368039">(Jul 08 2021 at 20:31)</a>:</h4>
<p>thank you for the rubber duck, at least :)</p>



<a name="245368470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245368470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Ardent <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245368470">(Jul 08 2021 at 20:34)</a>:</h4>
<p>yes, that definitely did the trick!</p>



<a name="245388663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245388663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245388663">(Jul 09 2021 at 00:43)</a>:</h4>
<p><span class="user-mention" data-user-id="240346">@Joe Ardent</span> Also, in the future, try <code>./x.py fmt</code>, which will run the right version of rustfmt with the right config even if that's not your normal rustfmt or cargo.</p>



<a name="245389098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245389098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Ardent <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245389098">(Jul 09 2021 at 00:50)</a>:</h4>
<p>OK, I'm updating the contrib doc to reflect that :) Thank you!</p>



<a name="245389202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245389202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245389202">(Jul 09 2021 at 00:52)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> Cargo doesn't use <code>x.py</code> or its formatting setup.   We currently only gate CI on stable rustfmt with no config settings.</p>



<a name="245389247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245389247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Ardent <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245389247">(Jul 09 2021 at 00:53)</a>:</h4>
<p>heh; I was about to come back to report its absence</p>



<a name="245389557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245389557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245389557">(Jul 09 2021 at 00:58)</a>:</h4>
<p><span class="user-mention" data-user-id="120518">@Eric Huss</span> Huh, I was under the impression that we still used <code>x.py fmt</code>. Good to know.</p>



<a name="245389586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setup%20for%20rustfmt/near/245389586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setup.20for.20rustfmt.html#245389586">(Jul 09 2021 at 00:59)</a>:</h4>
<p>Also, I've seen the same "unstable features are only available in nightly channel" when running <code>cargo fmt</code> with stable Rust, and I don't have a .rustfmt.toml locally.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>